package com.gtq.uhome.service.serviceImpl;


import com.gtq.uhome.mapper.UserPortOrderInforMapper;
import com.gtq.uhome.pojo.UserMsg;
import com.gtq.uhome.service.UserPortOrderInforService;
import com.gtq.uhome.vo.OrderInforBase;
import com.gtq.uhome.vo.SXOrderTwo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author ylhy
 * @Describe
 * @create 2020-08-10 10:32
 */
@Service(value = "userPortOrderInforService")
public class UserPortOrderInforServiceImpl implements UserPortOrderInforService {

    @Resource
    UserPortOrderInforMapper userPortOrderInforMapper;

    /**
     * 用户订单详情
     * @param map
     * @return
     */

    /**
     * 查看用户订单详情
     * @param map
     * @return
     */
    @Override
    public OrderInforBase userOrderInfor(Map<String, String> map) {
        OrderInforBase userOrderInfor = userOrderInfor = userPortOrderInforMapper.userOrderFailedInfor(map);
        SXOrderTwo[] sxOrderTwos = userPortOrderInforMapper.findSXOneTwo(map);


        userOrderInfor.setSXOrderTwoList(sxOrderTwos);

        return userOrderInfor;
    }

    /**
     * 查询用户消息
     * @param map
     * @return
     */
    @Override
    public List<UserMsg> findMsg(Map<String, Integer> map) {
        List<UserMsg> findMsg = userPortOrderInforMapper.findMsg(map);
        List<UserMsg> newList = new ArrayList<UserMsg>();
        for (UserMsg userMsg : findMsg) {
            if (userMsg.getMsg() != null || !userMsg.getMsg().equals("") || userMsg.getTime()!=null){
                newList.add(userMsg);
            }
        }
        return newList;
    }


}